package easy.x的平方根;

public class Solution {
    public int mySqrt(int x) {
        if (x == 0) {
            return 0;
        }
        int ans = (int) Math.exp(0.5 * Math.log(x));
        return (long) (ans + 1) * (ans + 1) <= x ? ans + 1 : ans;
    }

    public static void main(String[] args) {
        int x = 4;
        int x2 = 8;
        int x3 = 2147395600;
        Solution solution = new Solution();
        System.out.println(solution.mySqrt(x));
        System.out.println(solution.mySqrt(x2));
        System.out.println(solution.mySqrt(x3));
    }
}
